#include<stdio.h>
#include<unistd.h>
#include<assert.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/wait.h>

int main()
{
    pid_t id=fork();
    assert(id!=-1);
    if(id==0)
    {
        int cnt=50;
        while(cnt)
        {
            printf("i am child process\n");
            sleep(1);
            --cnt;
        }
        //int*p=NULL;
        //(*p)++;
        exit(10);
    }
    int status;
    pid_t ret=waitpid(id,&status,0);
    if(ret>0)
        printf("exit code:%d  sig:%d\n",(status>>8)&0xFF,status&0x7F);
    return 0;
}
